//
//  Book.m
//  UI17_SandBox
//
//  Created by dllo on 16/8/5.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "Book.h"

@implementation Book
// 2. 签订协议后 必须实现 下面两个方法
    // 初始化是 读取数据的
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];
    if (self) {
        _bookName = [aDecoder decodeObjectForKey:@"bookName"];
        _bookPrice = [aDecoder decodeObjectForKey:@"bookPrice"];
        _writer = [aDecoder decodeObjectForKey:@"writer"];
        _bookAddress = [aDecoder decodeObjectForKey:@"bookAddress"];
        _bookType = [aDecoder decodeObjectForKey:@"bookType"];
    }
    return self;
}
    // 写入数据的方法 赋值
- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:_bookName forKey:@"bookName"];
    [aCoder encodeObject:_bookPrice forKey:@"bookPrice"];
    [aCoder encodeObject:_writer forKey:@"writer"];
    [aCoder encodeObject:_bookAddress forKey:@"bookAddress"];
    [aCoder encodeObject:_bookType forKey:@"bookType"];
}



@end





